Lesson: 25 - Debugging

Purpose : Students should learn how to identify and correct errors (bugs) in Scratch projects. Debugging helps improve logical thinking, attention to detail, and resilience in solving problems.

Materials Required

Scratch 3.0

Curriculum Content 6.14) Debugging

Prior knowledge

Familiarity with all the Scratch concepts taught so far (Events, Loops, Variables, Clones, Custom Blocks…).

Exercises

Exercise:1



  1. Correct the following fruit catching game, in which the fruits are stored in the bottom. You have to delete them.

  2. Exercise Video




    Exercise:2



  3. Use the below link to download the program which has bugs and try to debug the code. See the video to understand what is the bug in the program.

Exercise Video




Solutions




Teacher's Instruction
  1. Introduce the term bug and explain it as a mistake or unexpected behavior in a program.
  2. Teach how to read code step-by-step.
  3. Explain strategies like: Checking variables, using the green flag to reset, breaking down large scripts into smaller parts to check if the different portions are working.
  4. Encourage students to predict what a script should do, compare with what it does, then trace the error.
  5. Allow students to work in pairs for peer-debugging.
  6. Ask them to think about what are some things they can do to reduce or avoid bugs.